package com.topone.permission.sercurity.service;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import com.topone.permission.utils.ControllerUtils;


/**
 *  url被限制拥有某个权限时,用户没有认证会调用此方法
 * @author XiaZhentao
 * @date 2018年12月1日
 */
@Component("myAuthenticationEntryPoint")
public class MyAuthenticationEntryPoint implements AuthenticationEntryPoint {

        @Override
        public void commence(HttpServletRequest request, HttpServletResponse response,
                             AuthenticationException exception) throws IOException, ServletException {
        	ControllerUtils.failedRepose(request, response, exception);
        }
    }